<?php
//--枚举
class Con_enum extends Acan{
	
	public $defaultAct='list';
	function __construct($ainfo=null){
		parent::__construct($ainfo=null);
		$this->model = Afun_db()->model(Acan_table_enum);
	}
	
	//添加
	function Act_show(){
		$key = $this->id;
		if(empty($key)){ echo '请先选择！';}
		$model = Afunc_enum()->model($key);
		$data = Afunc_enum()->data($key);
		include $this->Atpl();
	}
	//添加
	function Act_add(){
		include $this->Atpl();
	}
	function Act_up(){
		$model = $this->model->findPk($this->id);
		include $this->Atpl();
	}
	
	function Act_save(){
		$save = $_POST['save'];
		if($this->id){
			$rs = $this->model->updatePk($save,$this->id);
			Afunc_enum()->cache_del($this->id,$save['code']);
		}else{
			$rs = $this->model->save($save);
		}
		if($rs==1){$msg = '更新成功';}elseif($rs==0){$msg = '没有更新';}else{$msg = '更新失败';}
		echo $msg;
	}
	
	function Act_list(){
		$page->by = $this->model->key_name;
		$page->counts = $this->model->count();	//统计总数目
		$page->theurl = $this->Aactr.'-'.$this->id;
		$pages = Afun_apage($page);
		$con->order = "a.$pages->orderby";
		$con->limit = $pages->limit;
		//分页结束
		$list_mode = $this->model->findAll($con);
		include $this->Atpl();
	}
	
	
}

?>